import { DomWarBeaContentPannel } from "./DomWarBeaContentPannel";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FlowerBg } from "../../common/FlowerBg";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { DomWarAuctionCellRender } from "./DomWarAuctionCellRender";
import { AuctionCityRightPart } from "./otherPart/AuctionCityRightPart";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { SDominionAuctionCityInfo } from "../../../../../Message/Public/SDominionAuctionCityInfo";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { SecTimer } from "../../../../../com/gengine/core/frame/SecTimer";
import { TimerType } from "../../../../../com/gengine/core/frame/TimerType";
import { Cache } from "../../../cache/Cache";
import { ClockManager } from "../../../manager/ClockManager";
import { RemainTimeTool } from "../../award/RemainTimeTool";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class AuctionCityPannel
    
    export  class AuctionCityPannel extends DomWarBeaContentPannel
    {
        constructor(arg1: string="", arg2: Boolean=true, arg3: string="", arg4: number=590, arg5: number=480)
        {
            super(arg1, arg2, arg3, arg4, arg5);
            return;
        }

        protected /* override */ configUI(): void
        {
            this._bgBmp = new Object /* flash.display.Bitmap */();
            addChild(this._bgBmp);
            this._txtIntroBmp = new Object /* flash.display.Bitmap */();
            addChild(this._txtIntroBmp);
            this._txtIntroBmp.x = 69;
            this._txtIntroBmp.y = 0;
            ObjCreate.createGTextField(Language.getString(20969) + ":", 250, 20, 80, 20, this, GlobalStyle.textFormat6);
            this._titmeTxt = ObjCreate.createGTextField("00: 00: 00", 294, 20, 80, 20, this, GlobalStyle.textFormat6);
            super.configUI();
            this.flowBg = new FlowerBg(583, 479, false);
            this.addChild(this.flowBg);
            this._titleList = new GTileList();
            this._titleList.rowCount = 2;
            this._titleList.columnCount = 3;
            this._titleList.rowHeight = 215;
            this._titleList.columnWidth = 190;
            this._titleList.horizontalGap = 3;
            this._titleList.verticalGap = 2;
            this._titleList.setStyle("cellRenderer", DomWarAuctionCellRender);
            this._titleList.setStyle("skin", new Object /* flash.display.Bitmap */());
            this._titleList.setSize(580, 434);
            this.addChild(this._titleList);
            this._titleList.x = 2;
            this._titleList.y = 40;
            this._rightPart = new AuctionCityRightPart("", true, "", 205, 480);
            this._rightPart.show(this);
            this._rightPart.x = 590;
            return;
        }

        protected /* override */ onImageLoaded(): void
        {
            super.onImageLoaded();
            this._bgBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.DomWarAuctionCityBg);
            this._txtIntroBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.DWBTxtImage_auctionIntro);
            return;
        }

        public /* override */ update(arg1: Object): void
        {
            this.info = arg1 as SDominionAuctionCityInfo;
            if (this.info) 
            {
                this._rightPart.update(this.info);
                this._titleList.dataProvider = new DataProvider(this.info.dominionAuctionCitys);
            }
            return;
        }

        /* internal  */startTimer(): void
        {
            if (!this._secTimer) 
            {
                this._secTimer = new SecTimer(1);
                this._secTimer.addListener(TimerType.ENTERFRAME, this.onTimerRun);
            }
            this._secTimer.reset();
            this._secTimer.start();
            return;
        }

        /* internal  */onTimerRun(arg1: SecTimer): void
        {
            var loc1=NaN;
            if (Cache.instance.dominionBea.isAuctioning()) 
            {
                loc1 = Cache.instance.dominionBea.dateState.endDate.time - ClockManager.instance.nowDate.time;
                loc1 = loc1 / 1000;
                this._titmeTxt.text = RemainTimeTool.getRemainTimeBySeconds(loc1);
            }
            else 
            {
                this.stopTimer();
                this._titmeTxt.text = "00: 00: 00";
            }
            return;
        }

        /* internal  */stopTimer(): void
        {
            if (this._secTimer) 
            {
                this._secTimer.stop();
            }
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            this.stopTimer();
            return;
        }

        public /* override */ show(arg1: Object /* flash.display.DisplayObjectContainer */): void
        {
            super.show(arg1);
            this.startTimer();
            return;
        }

        /* internal */ /* var */_bgBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_txtIntroBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */flowBg: FlowerBg;

        /* internal */ /* var */_titleList: GTileList;

        /* internal */ /* var */_titmeTxt: GTextFiled;

        /* internal */ /* var */_secTimer: SecTimer;

        /* internal */ /* var */info: SDominionAuctionCityInfo;
    }
